<?php 
ob_start();
session_start();
$teamid=$_SESSION['teamID'];
if ($_SESSION['teamID']!=1){header('LOCATION:main.php');}
?>
<!DOCTYPE html>
<html>
<head>
<title>Coach</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="Content/bootstrap.css" rel="stylesheet" />
<link href="Content/bootstrap-datepicker3.css" rel="stylesheet" />
<link href="Content/site.css" rel="stylesheet" />
<script src="Scripts/jquery-1.9.1.js"></script>
<script src="Scripts/bootstrap.js"></script>
<script src="Scripts/bootstrap-datepicker.js"></script>
</head>
<body>
<?php include_once("php/coach_classes.php"); include("php/all_divisions.php");?>
<div class="container blue_border">
  <?php include_once("php/banner.php"); ?>
  <?php include_once("php/nav_bar.php"); ?>
  <h1>Add Final</h1>
  <div class="row">
    <div>
      <ul class="nav nav-tabs" id="myTab">
        <?php foreach($allRounds as $r){?>
        <li><a href="<?php echo "#".$r->roundID;?>" data-toggle="tab"><?php echo $r->round_number;?></a></li>
        <?php } ?>
      </ul>
      <div class="tab-content">
        <?php foreach($allRounds as $r){?>
        <div class="tab-pane" id="<?php echo $r->roundID;?>">
          <div class="row">
            <div class="col-md-10 col-md-offset-1">
              <form action="php/add_teams_to_round.php" method="post"  class="form" role="form">
                <input type="hidden"  id="roundID" name="roundID" value="<?php echo $r->roundID;?>" >
                <?php  foreach ($divisions as $d){	?>
                <div class="col-md-8 col-xs-12 padding_lr_5">
                  <h4><?php echo $d->division_name;?></h4>
                  <table class="table table-bordered">
                    <tbody>
                      <tr>
                        <td class="width25"><select class="form-control  no-padding" name="team1<?php echo $d->divisionID;?>" id="team1<?php echo $d->divisionID;?>">
                            <option value="0"> </option>
                            <?php $teams=$repTeam->maps($repTeam->getActiveTeams($d->divisionID)); 
										foreach ($teams as $t){?>
                            <option value="<?php echo $t->teamID; ?>"><?php echo $t->team_name; ?></option>
                            <?php } ?>
                          </select></td>
                        <td class="width5">vs</td>
                        <td class="width25"><select class="form-control  no-padding" name="team2<?php echo $d->divisionID;?>" id="team2<?php echo $d->divisionID;?>">
                            <option value="0"> </option>
                            <?php foreach ($teams as $t){ ?>
                            <option value="<?php echo $t->teamID; ?>"><?php echo $t->team_name; ?></option>
                            <?php } ?>
                          </select></td>
                        <td class="width14"><select class="form-control no-padding" name="table<?php echo $d->divisionID;?>" id="table<?php echo $d->divisionID;?>">
                            <option value="0">Table</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                          </select></td>
                        <td class="width14"> Final
                          <input type="checkbox" name="final<?php echo $d->divisionID;?>" id="final<?php echo $d->divisionID;?>" value="final"></td>
                      </tr>
                    </tbody>
                  </table>
                  <table class="table table-striped table-bordered">
                    <tbody>
                      <?php	$schedles=$repSchedule->maps($repSchedule->getScheduleByRoundIDAndDivisionID($r->roundID,$d->divisionID));
		  				foreach($schedles as $s){ 
		  					include("php/main_teams_open.php");?>
                      <tr>
                        <td class="width25"><?php echo $team1->team_name;?></td>
                        <td class="width5">vs</td>
                        <td class="width25"><?php echo $team2->team_name;?></td>
                        <td class="width14">Table <?php echo $s->Table;?></td>
                        <td class="width14"><?php echo $s->type;?></td>
                      </tr>
                      <?php }?>
                    </tbody>
                  </table>
                </div>
                <?php  }?>
                <div class="col-md-8 col-xs-12 padding_lr_5 align-center">
                <button class="btn btn-default btn-lg" type="submit" name="submit">Add</button>
              </form>
            </div>
          </div>
        </div>
      </div>
      <?php	} ?>
    </div>
  </div>
</div>
</div>
<?php ob_flush();?>
</body>
</html>
